package com.wfk.service.impl;

import com.wfk.entity.SysNews;
import com.wfk.mapper.SysNewsMapper;
import com.wfk.service.ISysNewsService;
import com.wfk.utils.ResponseData;
import com.wfk.utils.ValidateUtil;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;

import org.springframework.stereotype.Service;

/**
 * <p>
 * 新闻信息 服务实现类
 * </p>
 *
 * @since 2019-01-07
 */
@Service
public class SysNewsServiceImpl extends ServiceImpl<SysNewsMapper, SysNews> implements ISysNewsService {

	@Override
	public ResponseData deleteNews(Integer nid) {
		super.removeById(nid);
		return ResponseData.ok("操作成功");
	}

	@Override
	public ResponseData saveNews(SysNews sysNews) {
		if (!ValidateUtil.empty(sysNews.getTitle())) {
			return ResponseData.baseServiceError("标题不能为空");
		}
		if (!ValidateUtil.empty(sysNews.getContent())) {
			return ResponseData.baseServiceError("内容不能为空");
		}
		super.saveOrUpdate(sysNews);
		return ResponseData.ok();
	}


}
